<?php

class StringValidator {
	private $_maxLength=-1;
	/**
	 * Enter description here...
	 *
	 * @param unknown_type $length
	 * @return StringValidator
	 */
	public function setMaxLength($length){
		$this->_maxLength = $length;
		return $this;
	}
	private $_minLength=0;
	/**
	 * Enter description here...
	 *
	 * @param unknown_type $length
	 * @return StringValidator
	 */
	public function setMinLength($length){
		$this->_minLength = $length;
		return $this;
	}
	private $_allowedChars="";
	/**
	 * Enter description here...
	 *
	 * @param unknown_type $length
	 * @return StringValidator
	 */
	public function setAllowedChars($alowedChars){
		$this->_allowedChars = $alowedChars;
		return $this;
	}
	private $_errorString="";
	public function getErrorString(){
		return $this->_errorString;
	}
	public function __construct(){
		
	}
	public function validate($string){
		if(strlen($string)<$this->_minLength){
			$this->_errorString="Length shoud be greater than".$this->_minLength;
			return false;
		}
		if($this->_maxLength!=-1&&strlen($string)>$this->_maxLength){
			$this->_errorString="Length shoud be less than".$this->_maxLength;
			return false;
		}
		/*foreach ($this->_allowedChars as $char){
			var_dump($char);
		}*/
		return true;
	}
}

?>